#!/bin/sh

if [ ! -e /var/lib/otrs/Kernel/Config.pm ]; then
	echo "Initializing /var/lib/otrs/Kernel/Config.pm"
	cp /var/lib/otrs/Kernel/Config.pm.dist /var/lib/otrs/Kernel/Config.pm
fi

rm /var/lib/otrs/Kernel/Config.pm.dist

/var/lib/otrs/bin/otrs.SetPermissions.pl --web-group=www-data

if [ -e /var/lib/otrs/Kernel/Config/Files/ZZZAAuto.pm ]; then
	su -s /bin/sh otrs -c "/var/lib/otrs/bin/otrs.Console.pl Maint::Config::Rebuild"
	su -s /bin/sh otrs -c "/var/lib/otrs/bin/otrs.Console.pl Maint::Cache::Delete"
fi

exit 0
